home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / man / cat3 / XmResolvePartOffsets.z / XmResolvePartOffsets
Encoding:
Text File  |  2003-11-18  |  6.0 KB  |  133 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       _X_m_R_e_s_o_l_v_e_P_a_r_t_O_f_f_s_e_t_s - A function that allows    writing    of
  10.       upward-compatible applications and widgets
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       #include <Xm/XmP.h>
  14.  
  15.       void XmResolvePartOffsets (wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss,,,, ooooffffffffsssseeeetttt)
  16.            _W_i_d_g_e_t_C_l_a_s_swwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss;
  17.            _X_m_O_f_f_s_e_t_P_t_r**** ooooffffffffsssseeeetttt;
  18.  
  19.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  20.       The use of offset records requires one extra global variable
  21.       per widget class.  The variable consists of a    pointer    to an
  22.       array    of offsets into    the widget record for each part    of the
  23.       widget structure.  The _X_m_R_e_s_o_l_v_e_P_a_r_t_O_f_f_s_e_t_s function
  24.       allocates the    offset records needed by an application    to
  25.       guarantee upward-compatible access to    widget instance
  26.       records by applications and widgets.    These offset records
  27.       are used by the widget to access all of the widget's
  28.       variables.  A    widget needs to    take the following steps:
  29.  
  30.       +o    Instead of creating a resource list, the    widget creates
  31.            an offset resource list.     To help you accomplish    this,
  32.            use the _X_m_P_a_r_t_R_e_s_o_u_r_c_e structure    and the    _X_m_P_a_r_t_O_f_f_s_e_t
  33.            macro.  The _X_m_P_a_r_t_R_e_s_o_u_r_c_e data structure looks just
  34.            like a resource list, but instead of having one integer
  35.            for its offset, it has two shorts.  This    is put into
  36.            the class record    as if it were a    normal resource    list.
  37.            Instead of using    _X_t_O_f_f_s_e_t for the offset, the widget
  38.            uses _X_m_P_a_r_t_O_f_f_s_e_t.  XmPartResource resources[] =    {
  39.          { BarNxyz, BarCXyz, XmRBoolean,
  40.            sizeof(Boolean), XmPartOffset(Bar,xyz),
  41.            XmRImmediate, (XtPointer)False } };
  42.  
  43.       +o    Instead of putting the widget size in the class record,
  44.            the widget puts the widget part size in the same    field.
  45.  
  46.       +o    Instead of putting _X_t_V_e_r_s_i_o_n in the class record, the
  47.            widget puts _X_t_V_e_r_s_i_o_n_D_o_n_t_C_h_e_c_k in the class record.
  48.  
  49.       +o    The widget defines a variable, of type _X_m_O_f_f_s_e_t_P_t_r, to
  50.            point to    the offset record.  This can be    part of    the
  51.            widget's    class record or    a separate global variable.
  52.  
  53.       +o    In class    initialization,    the widget calls
  54.            _X_m_R_e_s_o_l_v_e_P_a_r_t_O_f_f_s_e_t_s, passing it    a pointer to contain
  55.            the address of the offset record    and the    class record.
  56.            This does several things:
  57.  
  58.       Adds the superclass (which, by definition, has already been
  59.       initialized) size field to the part size field
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 11/11/03)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.       Allocates an array based upon    the number of superclasses
  75.  
  76.       Fills    in the offsets of all the widget parts with the
  77.       appropriate values, determined by examining the size fields
  78.       of all superclass records
  79.  
  80.       Uses the part    offset array to    modify the offset entries in
  81.       the resource list to be real offsets,    in place
  82.  
  83.       +o    The widget defines a constant which will    be the index
  84.            to its part structure in    the offsets array.  The    value
  85.            should be 1 greater than    the index of the widget's
  86.            superclass.  Constants defined for all Xm widgets can
  87.            be found    in _X_m_P._h.  #define BarIndex (XmBulletinBIndex
  88.            + 1)
  89.  
  90.       +o    Instead of accessing fields directly, the widget    must
  91.            always go through the offset table.  The    _X_m_F_i_e_l_d    macro
  92.            helps you access    these fields.  Because the
  93.            _X_m_P_a_r_t_O_f_f_s_e_t and    _X_m_F_i_e_l_d    macros concatenate things
  94.            together, you must ensure that there is no space    after
  95.            the part    argument.  For example,    the following macros
  96.            do not work because of the space    after the part (Label)
  97.            argument:  XmField(w, offset, Label , text, char    *)
  98.            XmPartOffset(Label , text) Therefore, you must not have
  99.            any spaces after    the part (Label) argument, as
  100.            illustrated here:  XmField(w, offset, Label, text, char
  101.            *) You can define macros    for each field to make this
  102.            easier.    Assume an integer field    xxxxyyyyzzzz:
  103.            #define BarXyz(w) (*(int    *)(((char *) w)    + \
  104.          offset[BarIndex] + XtOffset(BarPart,xyz)))
  105.  
  106.       The parameters for _X_m_R_e_s_o_l_v_e_P_a_r_t_O_f_f_s_e_t_s are defined below:
  107.  
  108.       wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss
  109.            Specifies the widget class pointer for the created widget.
  110.  
  111.       ooooffffffffsssseeeetttt
  112.            Returns the offset record.
  113.  
  114.      RRRREEEELLLLAAAATTTTEEEEDDDD IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  115.       _X_m_R_e_s_o_l_v_e_A_l_l_P_a_r_t_O_f_f_s_e_t_s(_3_X).
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 11/11/03)
  130.  
  131.  
  132.  
  133.